//==================================================================
//  Copyright (C) 2006  Davide Pasca
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//==================================================================
//==
//==
//==
//==================================================================

#ifndef M5D_PNTSPRT_H
#define M5D_PNTSPRT_H

#include "m5d_model.h"
#include "m5d_verts.h"
#include "m5d_displist.h"

//==================================================================
namespace M5D {

//==================================================================
class PntSprt : public Model
{
private:
	Material		*_materialp;
	bool			_has_color;
	float			_max_size;
	DispListBase	*_displistp;
	int				_n_active_points;
	bool			_is_read_lock;
	bool			_is_write_lock;
	bool			_is_instance;

private:
	PntSprt( class Scene *scenep, const char *namep, int max_points, bool has_color );
	PntSprt( class Scene *scenep, const char *namep, PntSprt *copy_fromp );
public:
	~PntSprt();
	void			SetMaterial( M5D::Material *materialp )	{	_materialp = materialp;	}
	M5D::Material	*GetMaterial() const					{	return _materialp;		}

	void	SetActiveVerts( u_int n );

	u_int	GetActiveVerts() const			{	return _n_active_points;	}

	void	SetMaxSize( float max_size )	{	_max_size = max_size;		}
	float	GetMaxSize() const				{	return _max_size;			}

	// lock for write
	PackVert::PosCol	*BeginVertsPC( u_int from_idx=0, u_int n=0 )
	{
		PASSERT( !_is_write_lock );
		_is_write_lock = true;
		return (PackVert::PosCol *)_displistp->BeginVerts( from_idx, n );
	}

	// lock for write
	PackVert::Pos	*BeginVertsP( u_int from_idx=0, u_int n=0 )
	{
		PASSERT( !_is_write_lock );
		_is_write_lock = true;
		return (PackVert::Pos *)_displistp->BeginVerts( from_idx, n );
	}

	void	EndVerts();

	DispListBase	*GetDispList() {	return _displistp; }

	friend class	Model;
	friend class	Scene;
};

//==================================================================

};

#endif